package de.sendorian.app.forumArchive.renamer;


import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.List;

import de.sendorian.app.forumArchive.domain.File;

public class CompositeRenamer implements FileRenamer {

	private List<FileRenamer> renamers;


	public CompositeRenamer(FileRenamer... renamers) {
		this.renamers = Arrays.asList(renamers);
	}


	public CompositeRenamer(Collection<FileRenamer> renamers, FileRenamer additionalRenamer) {
		this.renamers = new ArrayList<FileRenamer>(renamers.size() + 1);
		this.renamers.addAll(renamers);
		this.renamers.add(additionalRenamer);
	}


	public void rename(File file) {
		for (FileRenamer renamer : renamers) {
			renamer.rename(file);
		}

	}


	public CompositeRenamer and(FileRenamer fileRenamer) {
		return new CompositeRenamer(renamers, fileRenamer);
	}

}
